<?php
/**
 * lzp300 2014-12-22
 */
class hzjm extends actionAbstract {


    /**
     * 构造函数
     * @var array
     */
    function __construct() {
        parent::__construct();
    }

    function index(){
        $active=4;
        $this->loadModel('sys','join');
        $this->loadHelper('extend');
        $this->loadHelper('image');
        $image = new image();
        
        if($_POST){
            $data=isset($_POST['data'])?$_POST['data']:'';
            if(trim($data['cpName'])==''){
                ajaxReturn('', "请填写公司名称！", 0);exit;
            }elseif(trim($data['cpAddress'])==''){
                ajaxReturn('', "请填写公司地址！", 0);exit;
            }elseif(trim($data['cpUserName'])==''){
                ajaxReturn('', "请填写联系人！", 0);exit;
            }elseif(trim($data['cpTel'])==''){
                ajaxReturn('', "请填写联系方式！", 0);exit;
            }elseif(trim($data['cpEmail'])==''){
                ajaxReturn('', "请填写电子邮箱！", 0);exit;
            }
            if(!empty($_FILES['imagefile_1'])){
                $return_1 = $image->updImg('imagefile_1', 0, 0);
                if (is_array($return_1)) {
                    ajaxReturn('', $return_1['text']."特种行业许可证", 0);exit;
                } else {
                    $data['license_one'] = $return_1;
                }
            }else{
                ajaxReturn('', "请上传特种行业许可证！", 0);exit;
            }
            
            if(!empty($_FILES['imagefile_2'])){
                $return_2 = $image->updImg('imagefile_2', 0, 0);
                if (is_array($return_2)) {
                    ajaxReturn('', $return_2['text']."消防安全检查合格证", 0);exit;
                } else {
                    $data['license_two'] = $return_2;
                }
            }else{
                ajaxReturn('', "请上传消防安全检查合格证！", 0);exit;
            }
            
            if(!empty($_FILES['imagefile_3'])){
                $return_3 = $image->updImg('imagefile_3', 0, 0);
                if (is_array($return_3)) {
                    ajaxReturn('', $return_3['text']."营业执照", 0);exit;
                } else {
                    $data['license_three'] = $return_3;
                }
            }else{
                ajaxReturn('', "请上传营业执照！", 0);exit;
            }
            
            $data['created']=time();
            
            $re=$this->sys->joinModel->insert($data);
            if($re){
                ajaxReturn('refurbish', "申请成功！", 1);exit;
            }else{
                ajaxReturn('', "申请失败！", 0);exit;
            }
        }
        
        include $this->loadWidget('homeTheme');
    }
    
    
    
}